<!--
Copyright 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->

<link rel="import" href="../ct-builder-grid.html">

<link rel="import" href="../ct-builder.html">
<link rel="import" href="../../model/ct-builder-list.html">
<link rel="import" href="../../model/ct-step-failure.html">

<script>
(function () {

var assert = chai.assert;

var kExampleFailures = [
  new CTStepFailure('layout_tests', "plugins/gesture-events-scrolled.html",
    {
      "WebKit Win7 (dbg)": {
        "actual": "CRASH",
        "masterUrl": "https://master-one",
        "failingBuildCount": 2,
      },
      "WebKit Mac10.6 (dbg)": {
        "actual": "CRASH",
        "masterUrl": "https://master-one",
        "failingBuildCount": 1,
      },
      "WebKit Mac10.7": {
        "actual": "TEXT",
        "masterUrl": "https://master-one",
        "failingBuildCount": 1,
      }
    }, 177164, 177165),
  new CTStepFailure('layout_tests', "plugins/transformed-events.html",
    {
      "WebKit Win7 (dbg)": {
        "actual": "TEXT",
        "masterUrl": "https://master-one",
        "failingBuildCount": 2,
      },
      "WebKit Mac10.7": {
        "actual": "CRASH",
        "masterUrl": "https://master-two",
        "failingBuildCount": 1,
      },
    }, 177164, 177165
  )
];

var kExampleBuilderLatestRevisions = {
  'WebKit Mac10.7': {
    blink: 177164,
  },
  'WebKit Mac10.6 (dbg)': {
    blink: 177166,
  },
  'WebKit Win7 (dbg)': {
    blink: 177166,
  },
};

describe('ct-builder-grid', function() {
  var grid;

  beforeEach(function(done) {
    grid = document.createElement('ct-builder-grid');
    grid.builderList = new CTBuilderList(kExampleFailures);

    setTimeout(done);
  });

  describe('builder grid UI', function() {
    it('should show all failing builders', function() {
      var builders = grid.shadowRoot.querySelectorAll('ct-builder');
      assert.lengthOf(builders, 4);
      assert.deepEqual(builders[0].builder, new CTBuilder(
          'https://master-one', 'WebKit Mac10.6 (dbg)', 1));
      assert.deepEqual(builders[1].builder, new CTBuilder(
          'https://master-one', 'WebKit Mac10.7', 1));
      assert.deepEqual(builders[2].builder, new CTBuilder(
          'https://master-two', 'WebKit Mac10.7', 1));
      assert.deepEqual(builders[3].builder, new CTBuilder(
          'https://master-one', 'WebKit Win7 (dbg)', 2));
    });
  });
});

})()
</script>
